package com.msmall.community.common.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import com.msmall.base.model.BaseObject;
import com.msmall.base.util.Constants;
import com.msmall.community.common.util.CommendUtil;


@Entity
@Table(name="base_commend")
public class Commend extends BaseObject{

	private static final long serialVersionUID = -1052872182716947020L;
	
	@Id
	@Column(name="commend_id")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long commendId;

	/**
	 * 推荐来源类型 ConstantDB.COMMEND_TYPE_
	 * 1:BBS 2Space 3问答 4知识
	 */
	@Column(name="commend_type")
	private Short commendType;

	/**
	 * 推荐的子类型，主要用来定位页面显示；参考constantDB.COMMEND_DISPLAY_ 
	 * 0: 默认值,需要修改否则不可使用
	 * 1：首页滚动图片
	 * 2：首页标题新闻
	 * 3: 首页栏目：推荐话题
	 * 4: 首页栏目：各地小吃
	 * 5: 首页栏目：旅游常识
	 * 6: 问答首页图片
	 * 7: 问答首页推荐问题
	 * 8: 妈妈关心的问题
	 * 9: 宝宝关心的问题
	 */
	@Column(name="commend_display")
	private Integer commendDisplay;
	
	/**
	 * 当推荐需要图片时
	 */
	@Column(name="image_name")
	private String imageName;
	
	@Column(name="image_path")
	private String imagePath;
	
	@Transient
	private String imageAlt;
	/**
	 * 1为正常等级 参考constantDB.COMMEND_LEVEL_
	 */
	@Column(name="commend_level")
	private Short commendLevel;
	
	/**
	 * 实体对应的数据库ID
	 */
	@Column(name="entity_id")
	private Long entityId;
	
	//参考 ConstantDB
	@Column(name="audit")
	private Short audit;

	@Column(name="auditor")
	private Long auditor;

	/**
	 * 推荐备注
	 */
	@Column(name="comments")
	private String comments;

	@Column(name="audit_time")
	@Temporal(TemporalType.TIMESTAMP)
	private Date auditTime;

	@Column(name="commend_time")
	@Temporal(TemporalType.TIMESTAMP)
	private Date commendTime;

	@Column(name="commender")
	private Long commender;
	
	/**
	 * 审核备注
	 */
	@Column(name="reason")
	private String reason;

	@Column(name="url")
	private String url;
	
	/**
	 * 1 true 0 false
	 */
	@Column(name="enabled")
	private Short enabled;
	
	/**
	 * 作为VO时，存放实体对象
	 */
	@Transient
	private Object obj;
	
	public Long getCommendId() {
		return commendId;
	}

	public void setCommendId(Long commendId) {
		this.commendId = commendId;
	}

	public Short getCommendType() {
		return commendType;
	}

	public void setCommendType(Short commendType) {
		this.commendType = commendType;
	}

	public Short getCommendLevel() {
		return commendLevel;
	}

	public void setCommendLevel(Short commendLevel) {
		this.commendLevel = commendLevel;
	}

	public Long getEntityId() {
		return entityId;
	}

	public void setEntityId(Long entityId) {
		this.entityId = entityId;
	}

	public Long getAuditor() {
		return auditor;
	}

	public void setAuditor(Long auditor) {
		this.auditor = auditor;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public Date getAuditTime() {
		return auditTime;
	}

	public void setAuditTime(Date auditTime) {
		this.auditTime = auditTime;
	}

	public Date getCommendTime() {
		return commendTime;
	}

	public void setCommendTime(Date commendTime) {
		this.commendTime = commendTime;
	}

	public Long getCommender() {
		return commender;
	}

	public void setCommender(Long commender) {
		this.commender = commender;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public Short getAudit() {
		return audit;
	}

	public void setAudit(Short audit) {
		this.audit = audit;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Short getEnabled() {
		return enabled;
	}

	public void setEnabled(Short enabled) {
		this.enabled = enabled;
	}

	public Integer getCommendDisplay() {
		return commendDisplay;
	}

	public void setCommendDisplay(Integer commendDisplay) {
		this.commendDisplay = commendDisplay;
	}

	public String getImageName() {
		return imageName;
	}

	public void setImageName(String imageName) {
		this.imageName = imageName;
	}

	public String getImagePath() {
		return imagePath;
	}

	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}

	public String getImageAlt() {
		return imageAlt;
	}

	public void setImageAlt(String imageAlt) {
		this.imageAlt = imageAlt;
	}

	public String getHtmlImage(){
		return CommendUtil.getHomePath(commendId, Constants.USER_AGENT_TYPE_HTML) + imageName;
	}
	
	public String getWmlImage(){
		return CommendUtil.getHomePath(commendId, Constants.USER_AGENT_TYPE_WML) + imageName;
	}
	
	public Object getObj() {
		return obj;
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}

	public boolean equals(Object o) {
		return false;
	}

	public int hashCode() {
		return 0;
	}

	public String toString() {
		return null;
	}


}
